#include "bmp.c"
#include "Observer.h"
#include "Scene.h"
#include "Sphere.h"
#include "Light.h"
#include "Plan.h"
#include "Triangle.h"
#include "Quadric.h"
#include "Box.h"
#include "Texture.h"
#include "Torus.h"
#include <time.h>
#include "Parametrage.h"

int main()
{	
	BMPImage *bmp;
	Observer *obs;
	Scene *myScene;
	Sphere *mySphere, *mySphere2;
	Plan *myPlan, *myPlan2, *myPlan3, *myPlan4;
	Triangle *myTriangle;
	Quadric *myQuadric;
	Image *myRender = new Image(WIDTH,HEIGHT);
	Light *myLight1, *myLight2;
	int i;

	srand(time(NULL));
	obs=new Observer(Point(-13.0,0.0,25.0),Point(0.0,0.0,0.0),45,WIDTH);
	myScene=new Scene(obs,Color(0.8,0.8,0.8),WIDTH,HEIGHT, Color(1,1,1));

	mySphere=new Sphere(Point(-1.0,7.0,0.0),4.1);
	mySphere->setColor(Color(1,0,1));
	mySphere->setSpecular(Color(0.5,0.5,0.5));
	mySphere->setDiffusionCoefficient(0.5);
	mySphere->setSpecularCoefficient(0.45);
	mySphere->setRugositeCoefficient(50);
	mySphere->setMirorReflexion(0.0);
	mySphere->setBumpMapping(1.0);
	//mySphere->setTexture("mario.bmp");

	mySphere2=new Sphere(Point(5.0,5.0,3.0),1);
	mySphere2->setColor(Color(1,0,0));
	mySphere2->setSpecular(Color(0.5,1,0.5));
	mySphere2->setDiffusionCoefficient(0.5);
	mySphere2->setSpecularCoefficient(0.45);
	mySphere2->setRugositeCoefficient(50);
	mySphere2->setMirorReflexion(0.0);
	mySphere2->setBumpMapping(1.0);

	myPlan = new Plan(Point(9.0,0.0,0.0), Vector(-4.0,0.0,-1.0));
	myPlan->setColor(Color(1.0,0.0,1.0));
	myPlan->setSpecular(Color(1,1,1));
	myPlan->setDiffusionCoefficient(0.6);
	myPlan->setSpecularCoefficient(0.45);
	myPlan->setRugositeCoefficient(50);
	myPlan->setMirorReflexion(1.0);
	myPlan->setBumpMapping(0.0);
	//myPlan->setTexture("mario.bmp");

	myPlan2 = new Plan(Point(0.0,0.0,50.0), Vector(0.0,0.0,1.0));
	myPlan2->setColor(Color(1,0,0));
	myPlan2->setSpecular(Color(0.5,1,0.5));	
	myPlan2->setDiffusionCoefficient(0.6);
	myPlan2->setSpecularCoefficient(0.45);
	myPlan2->setRugositeCoefficient(50);
	myPlan2->setMirorReflexion(0.0);
	myPlan2->setBumpMapping(0.0);

	myPlan3 = new Plan(Point(20.0,0.0,0.0), Vector(-4.0,0.0,0.0));
	myPlan3->setColor(Color(0.0,0.0,1.0));
	myPlan3->setSpecular(Color(1,1,1));
	myPlan3->setDiffusionCoefficient(0.6);
	myPlan3->setSpecularCoefficient(0.45);
	myPlan3->setRugositeCoefficient(50);
	myPlan3->setMirorReflexion(0.0);
	myPlan3->setBumpMapping(0.0);
	//myPlan->setTexture("mario.bmp");

	myPlan4 = new Plan(Point(21.0,0.0,0.0), Vector(0.0,0.0,-1.0));
	myPlan4->setColor(Color(0.0,0.0,0.0));
	myPlan4->setSpecular(Color(1,1,1));
	myPlan4->setDiffusionCoefficient(0.6);
	myPlan4->setSpecularCoefficient(0.45);
	myPlan4->setRugositeCoefficient(50);
	myPlan4->setMirorReflexion(0.0);
	myPlan4->setBumpMapping(0.0);
	//myPlan->setTexture("mario.bmp");

	myTriangle = new Triangle(Point(9.0,4.0,0.0),Point(4.0,-10.0,0.0),Point(4.0,8.0,0.0));
	myTriangle->setColor(Color(1,1,0));
	myTriangle->setSpecular(Color(0.0,0.0,0.0));
	myTriangle->setDiffusionCoefficient(0.6);
	myTriangle->setSpecularCoefficient(0.45);
	myTriangle->setRugositeCoefficient(50);
	myTriangle->setMirorReflexion(0.0);
	myTriangle->setBumpMapping(5.0);
	//myTriangle->setTexture("mario.bmp");

	myQuadric = new Quadric(Point(0.0,0.0,0.0),1.0,2.0,1.0,0,0,0,0,0.0,0,-8);
	myQuadric->setColor(Color(0,1,1));
	myQuadric->setSpecular(Color(1.0,1,1.0));
	myQuadric->setDiffusionCoefficient(0.6);
	myQuadric->setSpecularCoefficient(0.45);
	myQuadric->setRugositeCoefficient(50);
	myQuadric->setMirorReflexion(0.0);
	myQuadric->setBumpMapping(10);
	//myQuadric->setTexture("mario.bmp");

/////////////////// Box //////////////////////////////
	Box* box = new Box(Point(-5.0,-5.0,0.0),6.0,4.0,8.0,0.0,0.3);
	box->setColor(Color(0.5,1.0,0.3));
	box->setSpecular(Color(1.0,1.0,1.0));
	box->setDiffusionCoefficient(0.6);
	box->setSpecularCoefficient(0.45);
	box->setRugositeCoefficient(50);
	box->setMirorReflexion(0.0);
	box->setBumpMapping(20.0);
	//box->setTexture("mario.bmp");

	Torus* myTorus = new Torus(Point(0.0,0.0,0.0),3.0,1.0,1.8,0);
	myTorus->setColor(Color(1.0,0.0,1.0));
	myTorus->setSpecular(Color(1.0,1.0,1.0));
	myTorus->setDiffusionCoefficient(0.6);
	myTorus->setSpecularCoefficient(0.45);
	myTorus->setRugositeCoefficient(50);
	myTorus->setMirorReflexion(0.0);
	myTorus->setTexture("mario.bmp");

	myLight1 = new Light(Color(1,1,1), Point(-5.0,5.0,25.0));

	//myLight2 = new Light(Color(1,1,1), Point(-10,-20,5));	
	//myScene->addObject(mySphere2);
	myScene->addObject(mySphere);

	myScene->addObject(myPlan);
	/*myScene->addObject(myPlan2);
	myScene->addObject(myPlan3);
	myScene->addObject(myPlan4);*/
	myScene->addObject(myTriangle);

	myScene->addObject(myQuadric);

	myScene->addObject(box);
	//myScene->addObject(myTorus);

	
	myScene->addLight(myLight1);
//	myScene->addLight(myLight2);
	
	myScene->traceRay(*myRender);

	bmp=Create_Image("toto.bmp",WIDTH,HEIGHT);
	bmp->pic = myRender->getPic();	
	WriteBitmap("toto.bmp",bmp);
}

